<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="${path}/css/editTable.css">
    
    <script type="text/javascript">
    	function check(){
    		var gateway_id = document.getElementById("gateway_id").value;
    		if("" == gateway_id || "0" == gateway_id){
     			alert("请选择业务长号码");
     			return false;
     		}
    		
     		var sync_url = document.getElementById("sync_url").value;
     		if("" == sync_url){
     			alert("请输入路由地址");
     			return false;
     		}
     		
     		var lower_id = document.getElementById("lower_id").value;
     		if("" == lower_id || "0" == lower_id){
     			alert("请选择渠道名称");
     			return false;
     		}
    		
    		var name = document.getElementById("name").value;
     		if("" == name){
     			alert("请输入路由名称");
     			return false;
     		}
    	}
    </script>
  </head>
  <body>
    <div>
    	<form id="editRouterForm" name="editRouterForm" method="post" action="${path }/router/updateRouter.action" onsubmit="return check();">
    		<p>填写路由信息</p>
    		<c:choose>
    			<c:when test="${routerVo.id == null}">
    				<input type="hidden" name="routerVo.id" value="0" />
    			</c:when>
    			<c:otherwise>
    				<input type="hidden" name="routerVo.id" value="${routerVo.id }" />
    			</c:otherwise>
    		</c:choose>
    		<table>
    			<tr>
    				<td>业务长号码</td>
    				<td>
    					<select id="gateway_id" name="routerVo.gateway_id">
    						<option value="0">--请选择--</option>
    						<c:if test="${gatewayVoList != null && fn:length(gatewayVoList) > 0 }">
    							<c:forEach items="${gatewayVoList }" var="gatewayVo" varStatus="i">
    								<option value="${gatewayVo.id }" <c:if test="${gatewayVo.id == routerVo.gateway_id }">selected="selected"</c:if>>${gatewayVo.sp_number }</option>
    							</c:forEach>
    						</c:if>
    					</select>
    					<span style="color: red;size: 2px;">&nbsp;*必选项</span>
    				</td>
    			</tr>
    			<tr>
    				<td>路由地址</td>
    				<td>
    					<input type="text" id="sync_url" name="routerVo.sync_url" value="${routerVo.sync_url }" />
    					<span style="color: red;size: 2px;">&nbsp;*必填项(从渠道处获得)&nbsp;&nbsp;格式:http://127.0.0.1:8080/test/test.html</span>
    				</td>
    			</tr>
    			<tr>
    				<td>渠道名称</td>
    				<td>
    					<select id="lower_id" name="routerVo.lower_id">
    						<option value="0">--请选择--</option>
    						<c:if test="${partnerLowerVoList != null && fn:length(partnerLowerVoList) > 0 }">
    							<c:forEach items="${partnerLowerVoList }" var="partnerLowerVo" varStatus="i">
    								<option value="${partnerLowerVo.id }" <c:if test="${partnerLowerVo.id == routerVo.lower_id }">selected="selected"</c:if>>${partnerLowerVo.name }</option>
    							</c:forEach>
    						</c:if>
    					</select>
    					<span style="color: red;size: 2px;">&nbsp;*必选项</span>
    				</td>
    			</tr>
    			<tr>
    				<td>路由名称</td>
    				<td>
    					<input type="text" id="name" name="routerVo.name" value="${routerVo.name }" />
    					<span style="color: red;size: 2px;">&nbsp;*必填项</span>
    				</td>
    			</tr>
    			<tr>
    				<td>路由详情</td>
    				<td>
    					<input type="text" id="detail" name="routerVo.detail" value="${routerVo.detail }" />
    				</td>
    			</tr>
    			<tr>
    				<td colspan="2">
    					<input type="submit" name="submit" value="确认" />
    				</td>
    			</tr>
    		</table>
    	</form>
    </div>
  </body>
</html>